import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;

public class Solution2251 {
    public int[] fullBloomFlowers(int[][] flowers, int[] persons) {
        TreeSet<Integer> treeSet=new TreeSet<>();
        for (int[] flower : flowers) {
            treeSet.add(flower[0]);
            treeSet.add(flower[1]);
        }
        for (int person : persons) {
            treeSet.add(person);
        }
        Map<Integer,Integer> map=new HashMap<>();
        int id=0;
        for (Integer integer : treeSet) {
            map.put(integer,id);
            id++;
        }
        int[] f=new int[id+1];
        for (int[] flower : flowers) {
            f[map.get(flower[0])]++;
            f[map.get(flower[1])+1]--;
        }
        int[] sum=new int[id];
        sum[0]=f[0];
        for (int i=1;i<id;i++){
            sum[i]=sum[i-1]+f[i];
        }
        int[] ans=new int[persons.length];
        for (int i=0;i<persons.length;i++){
            ans[i]=sum[map.get(persons[i])];
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Solution2251().fullBloomFlowers(new int[][]{{1, 6}, {3, 7}, {9, 12}, {4, 13}}, new int[]{2, 3, 7, 11})));
    }
}
